package com.taoym.voucher.xcx.service.impl;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.taoym.voucher.xcx.domain.XcxText;
import com.taoym.voucher.xcx.entity.vo.XcxGetTextVO;
import com.taoym.voucher.xcx.mapper.XcxTextMapper;
import com.taoym.voucher.xcx.service.XcxTextService;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;

import javax.annotation.Resource;
import java.util.List;

/**
 * @coder taoym
 * @datetime 2021/8/17 14:31
 * @desc
 */
@Service
public class XcxTextServiceImpl implements XcxTextService {

    @Resource
    private XcxTextMapper xcxTextMapper;

    @Override
    public List<XcxGetTextVO> getXcxTexts(Integer type) {

        XcxText text = xcxTextMapper.selectOne(new QueryWrapper<XcxText>().select("text").eq("type", type));
        if(ObjectUtils.isEmpty(text)){
            return null;
        }
        return JSON.parseArray(text.getText(), XcxGetTextVO.class);
    }
}
